<?php

/**
 * Cliente filter form base class.
 *
 * @package    sms
 * @subpackage filter
 * @author     Patricio Andrés Córdova De La Cruz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseClienteFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cedula'             => new sfWidgetFormFilterInput(),
      'nombre_cliente'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'apellido_cliente'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'nombre_preferido'   => new sfWidgetFormFilterInput(),
      'telefono_domicilio' => new sfWidgetFormFilterInput(),
      'celular'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'email'              => new sfWidgetFormFilterInput(),
      'id_operadora'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Operadora'), 'add_empty' => true)),
      'fecha_nacimiento'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'observaciones'      => new sfWidgetFormFilterInput(),
      'id_sucursal'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Sucursal'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'cedula'             => new sfValidatorPass(array('required' => false)),
      'nombre_cliente'     => new sfValidatorPass(array('required' => false)),
      'apellido_cliente'   => new sfValidatorPass(array('required' => false)),
      'nombre_preferido'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'telefono_domicilio' => new sfValidatorPass(array('required' => false)),
      'celular'            => new sfValidatorPass(array('required' => false)),
      'email'              => new sfValidatorPass(array('required' => false)),
      'id_operadora'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Operadora'), 'column' => 'id_operadora')),
      'fecha_nacimiento'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'observaciones'      => new sfValidatorPass(array('required' => false)),
      'id_sucursal'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Sucursal'), 'column' => 'id_sucursal')),
    ));

    $this->widgetSchema->setNameFormat('cliente_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Cliente';
  }

  public function getFields()
  {
    return array(
      'id_cliente'         => 'Number',
      'cedula'             => 'Text',
      'nombre_cliente'     => 'Text',
      'apellido_cliente'   => 'Text',
      'nombre_preferido'   => 'Number',
      'telefono_domicilio' => 'Text',
      'celular'            => 'Text',
      'email'              => 'Text',
      'id_operadora'       => 'ForeignKey',
      'fecha_nacimiento'   => 'Date',
      'observaciones'      => 'Text',
      'id_sucursal'        => 'ForeignKey',
    );
  }
}
